﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sy2_6
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            textBox1.Text = "1890";
            textBox2.Text = DateTime.Now.Year.ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            textBox3.Text = "";
            try
            {
                int startYear = int.Parse(textBox1.Text);
                int endYear = int.Parse(textBox2.Text);
                for (int i = startYear; i <= endYear; i++)
                {
                    if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0)
                    {
                        textBox3.Text += i.ToString() + "\t";
                    }
                }
            }
            catch (FormatException)
            {
                MessageBox.Show("请输入有效的年份数字！", "输入错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}
